;; Examples of apply, map, and for-each functions

;; apply examples
(display "Apply examples:")
(newline)
(display (apply + '(1 2 3 4 5)))  ; Should output 15
(newline)
(display (apply cons '(1 2)))     ; Should output (1 . 2)
(newline)
(display (apply + 1 2 '(3 4)))    ; Should output 10 (1+2+3+4)
(newline)

;; map examples
(display "Map examples:")
(newline)
(display (map (lambda (x) (* x x)) '(1 2 3 4)))     ; Should output (1 4 9 16)
(newline)
(display (map + '(1 2 3) '(4 5 6)))                 ; Should output (5 7 9)
(newline)
(display (map car '((1 2) (3 4) (5 6))))           ; Should output (1 3 5)
(newline)

;; for-each examples
(display "For-each examples:")
(newline)
(for-each display '(1 2 3))        ; Should output 123
(newline)
(for-each (lambda (x) (display (* x x)) (display " ")) '(1 2 3 4))  ; Should output 1 4 9 16
(newline)